<%@page import="com.mto.module.karaoke.model.Category"%>
<%@page import="java.util.List"%>
<%@page import="com.mto.module.karaoke.service.CategoryServiceUtil"%>
<%@page import="com.mto.module.karaoke.service.CategoryLocalServiceUtil"%>
<%@ include file="/jsps/main.jsp"%>

<%
PortletURL actionUrl = renderResponse.createActionURL();
PortletURL renderUrl = renderResponse.createRenderURL();
renderUrl.setParameter("tab", "quan-tri-danh-muc");

actionUrl.setParameter(ActionRequest.ACTION_NAME, "updateCategory");
PortletURL redirectUrl = renderResponse.createRenderURL();
redirectUrl.setParameter("jspPage", "/jsps/quan-tri/category/list.jsp");
redirectUrl.setParameter("tab", "quan-tri-danh-muc");
actionUrl.setParameter("redirectUrl", redirectUrl.toString());

long categoryId = ParamUtil.getLong(request, "categoryId");
Category category = null;
String name = "", action = "save", strCategoryId = String.valueOf(categoryId);

if(categoryId > 0) {
	category = CategoryLocalServiceUtil.getCategory(categoryId);
	name = category.getName();
	action = "update";
}
%>

<aui:layout cssClass="portlet-layout">
	<aui:column cssClass="aui-w20 portlet-column portlet-column-first">
		<div class="portlet-column-content portlet-column-content-first">
			<ul class="karaoke-menu">
				<% 
				renderUrl.setParameter("jspPage", "/jsps/quan-tri/category/list.jsp"); 
				%>
				<li><a href="<%=renderUrl.toString()%>"><liferay-ui:message key="danh-sach-cac-bai-hat"/></a></li>
				
				<c:if test="<%= category != null %>">
					<% 
					renderUrl.setParameter("jspPage", "/jsps/quan-tri/category/update.jsp"); 
					%>
					<li><a href="<%=renderUrl.toString()%>"><liferay-ui:message key="tao-danh-muc"/></a></li>
					
					<% 
					renderUrl.setParameter("jspPage", "/jsps/quan-tri/category/list.jsp"); 
					%>
					<li><a href="<%=renderUrl.toString()%>"><liferay-ui:message key="xem-bai-hat"/></a></li>
				</c:if>
			</ul>
		</div>
			
	</aui:column>
	<aui:column cssClass="aui-w80 portlet-column portlet-column-last">
		<div class="portlet-column-content portlet-column-content-last">
			<liferay-ui:error key="name-required" message="songName-required" />
			<aui:form action="<%=actionUrl.toString() %>">
				<aui:fieldset>
					<aui:input name="categoryId" value="<%=categoryId %>" type="hidden"/>
					<aui:input name="name" inputCssClass="input-100" label="name" value="<%=name %>"/>
					<aui:button type="submit" value="<%=action %>"/>
				</aui:fieldset>
			</aui:form>
		</div>
	</aui:column>
</aui:layout>